#include "assist.h"

#include <QOpenGLShaderProgram>

void initializeProgramOrFail(QOpenGLShaderProgram* program,
                             QString vertexShaderPath, QString fragmentShaderPath)
{
    if (!program->addShaderFromSourceFile(QOpenGLShader::Vertex, vertexShaderPath)) {
        qDebug() << "QOpenGLShaderProgram error encountered, log: " << program->log();
        qFatal("initializePipeline(): error adding vertex shader");
    }

    if (!program->addShaderFromSourceFile(QOpenGLShader::Fragment, fragmentShaderPath)) {
        qDebug() << "QOpenGLShaderProgram error encountered, log: " << program->log();
        qFatal("initializePipeline(): error adding fragment shader");
    }

    if (!program->link()) {
        qDebug() << "QOpenGLShaderProgram error encountered, log: " << program->log();
        qFatal("initializePipeline(): error linking");
    }

}
